<?php
/**
 * Created by PhpStorm.
 * User: phc
 * Date: 19-8-13
 * Time: 下午1:32
 */

namespace app\index\controller;

use app\common\model\ProductsModel;
use think\Controller;

class ProductController extends Controller
{
    public function index()
    {
        $this->assign([
            'url' => '/index/product/productList',
            'type' => 'product',
            'title' => '产品'
        ]);

        return $this->fetch('/list');
        //return $this->fetch('/product');
    }

    public function productList()
    {
        $productModel = new ProductsModel();
        $result = $productModel->getProduct();

        return zbcjson($result);
    }

    public function detail($id = 0)
    {
        $productModel = new ProductsModel();
        $detail = $productModel->getProductById($id);
        $this->assign([
            'url' => $detail['image'][0]['phy'] ? $detail['image'][0]['phy'] : '',
            'gradient' => $detail['data']['title'] ? $detail['data']['title'] : '',
            'subhead' => $detail['data']['createtime'] ? $detail['data']['createtime'] : '',
            'detail' => $detail['data']['detail'] ? $detail['data']['detail'] : ''
        ]);

        return $this->fetch('/detail');
    }
}